<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot-scope="{ row }" slot="status">
        <p v-if="row.status == 0" class="blue-normal">正常</p>
        <p v-else-if="row.status == 1">
          <span class="red-normal">已禁用</span>

          <el-tooltip
            class="item"
            effect="dark"
            :content="'诚信值低于0'"
            placement="bottom"
          >
            <i class="el-icon-question" style="margin-left: 4px"></i>
          </el-tooltip>
        </p>
      </template>
      <template slot-scope="{ row }" slot="ReviewStatus">
        <p v-if="row.ReviewStatus == 0" class="blue-normal">待审核</p>
        <p v-else-if="row.ReviewStatus == 1" class="green-normal">已通过</p>
        <p v-else-if="row.ReviewStatus == 2">
          <span class="red-normal">已驳回</span>
          <el-tooltip
            class="item"
            effect="dark"
            :content="'驳回原因'"
            placement="bottom"
          >
            <i class="el-icon-question" style="margin-left: 4px"></i>
          </el-tooltip>
        </p>
      </template>
    </avue-crud>
  </basic-container>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  data() {
    return {
      form: {},
      query: {},
      loading: false,
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
      },
      selectionList: [],
      option: {
        menu: false,
        menuType: "button",
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShow: false,
        searchMenuSpan: 6,
        border: false,
        index: false,
        indexLabel: "序号",
        searchBtnText: "提交",
        searchBtnIcon: "提交",
        emptyBtnText: "重置",
        emptyBtnIcon: "重置",
        viewBtn: false,
        addBtn: false,
        addBtnText: "添加",
        addBtnIcon: "el-icon-plus",
        editBtn: false,
        editBtnText: "",
        selection: false,
        dialogClickModal: false,
        delBtn: false,
        delBtnText: "",
        labelWidth: 110,
        searchLabelWidth: 100,
        column: [
          {
            label: "推广成员",
            prop: "PromotionMember",
          },
          {
            label: "产生推广费",
            prop: "PromotionFee",
          },
          {
            label: "关联时间",
            prop: "CorrelationTime",
          },
        ],
      },
      data: [
        {
          PromotionMember: "草草草草",
          PromotionFee: "52.03",
          CorrelationTime: "2025-10-10 12:13:13",
        },
      ],
      currentItemData: null,
    };
  },
  computed: {
    ...mapGetters(["permission"]),

    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.user_add, true),
        viewBtn: this.vaildData(this.permission.user_view, true),
        delBtn: this.vaildData(this.permission.user_delete, true),
        editBtn: this.vaildData(this.permission.user_edit, true),
      };
    },
  },
  mounted() {},
  methods: {
    beforeOpen(done, type) {
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, search = {}) {
      return;
      this.loading = true;
      let param = {
        page: page.currentPage,
        size: page.pageSize,
      };

      getUsedCarPageList({ ...param, ...search }).then((res) => {
        const resData = res.data;
        this.page.total = resData.total;
        this.data = resData.list;
        this.loading = false;
        this.selectionClear();
      });
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
  },
};
</script>

<style lang="scss" scoped></style>
